{% extends 'base/base.html' %}
{% load i18n %}
{% load account %}

{% block title %}登录 - 妙趣拾光锦盒{% endblock %}

{% block content %}
<section class="py-5">
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-md-6">
        <div class="card shadow">
          <div class="card-body p-5">
            <h2 class="card-title text-center mb-4">用户登录</h2>
            
            <form class="login" method="POST" action="{% url 'account_login' %}">
              {% csrf_token %}
              
              {% if form.errors %}
              <div class="alert alert-danger">
                <p>登录信息有误，请检查您的账号和密码。</p>
              </div>
              {% endif %}
              
              {% if redirect_field_value %}
              <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
              {% endif %}
              
              <div class="mb-3">
                <label for="id_login" class="form-label">用户名：</label>
                <input type="text" name="login" placeholder="您的用户名" class="form-control" autocomplete="username" required id="id_login">
              </div>
              
              <div class="mb-3">
                <label for="id_password" class="form-label">密码：</label>
                <input type="password" name="password" placeholder="您的密码" class="form-control" autocomplete="current-password" required id="id_password">
                <div class="form-text text-end">
                  <a href="{% url 'account_reset_password' %}" class="text-decoration-none">忘记密码?</a>
                </div>
              </div>
              
              <div class="mb-3 form-check">
                <input type="checkbox" name="remember" class="form-check-input" id="id_remember">
                <label class="form-check-label" for="id_remember">记住我</label>
              </div>
              
              <div class="d-grid gap-2">
                <button class="btn btn-primary" type="submit">登录</button>
              </div>
            </form>
            
            <div class="text-center mt-4">
              <p>如果您还没有创建账号，请先 <a href="{% url 'account_signup' %}" class="text-decoration-none">注册</a>。</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
{% endblock %} 